local skel = fk.CreateSkill {
  name = "emo__shijiandq",
  tags = {Skill.Permanent},
}

skel:addEffect(fk.EnterDying, {
  anim_type = "offensive",
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(skel.name) and target ~= player and data.damage and data.damage.from == player
  end,
  on_cost = Util.TrueFunc,
  on_use = function (self, event, target, player, data)
    player.room:addTableMarkIfNeed(player, "emo__shijiandq_owner", target.id) -- 存自己身上，防止丢失
    player.room:setPlayerMark(target, "@@emo__shijiandq", player.id)
  end,
})

skel:addEffect(fk.Death, {
  anim_type = "drawcard",
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(skel.name) and table.contains(player:getTableMark("emo__shijiandq_owner"), target.id)
  end,
  on_cost = Util.TrueFunc,
  on_use = function (self, event, target, player, data)
    local room = player.room
    if target.maxHp > 0 then
      room:changeMaxHp(player, target.maxHp)
    end
    local cards = target:getCardIds("h")
    if #cards > 0 and not player.dead then
      room:obtainCard(player, cards, false, fk.ReasonPrey, player, skel.name)
    end
  end,
})

skel:addEffect("prohibit", {
  prohibit_use = function (self, player, card)
    return player:getMark("@@emo__shijiandq") ~= 0 and card
  end,
})

skel:addEffect("invalidity", {
  invalidity_func = function(self, player, skill)
    return player:getMark("@@emo__shijiandq") ~= 0 and not (skill.name:endsWith("&"))
  end,
})

Fk:loadTranslationTable{
  ["emo__shijiandq"] = "时间夺取",
  [":emo__shijiandq"] = "持恒技，当你使一名其他角色进入濒死状态时，令该角色进入时间夺取状态，其无法使用技能和牌，当其死亡时，你获得其体力上限和手牌。",

  ["@@emo__shijiandq"] = "时间夺取",
}


return skel
